﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Entity;
using FluentNHibernate.Mapping;


namespace PropertyManagement.Domain.Mapping.FluentHibernate
{
    public class JobBookingMap : ClassMap<JobBooking>
    {
        public JobBookingMap()
        {
            Table("JobBooking");
            Id(x => x.ID).Column("ID").GeneratedBy.Identity();
            Map(x => x.JobDateTime).Column("JobDateTime");
            Map(x => x.FromAddressLine1).Column("FromAddressLine1");
            Map(x => x.FromAddressLine2).Column("FromAddressLine2");
            Map(x => x.FromCity).Column("FromCity");
            Map(x => x.FromCounty).Column("FromCounty");
            Map(x => x.FromPostcode).Column("FromPostcode");
            Map(x => x.ToAddressLine1).Column("ToAddressLine1");
            Map(x => x.ToAddressLine2).Column("ToAddressLine2");
            Map(x => x.ToCity).Column("ToCity");
            Map(x => x.ToCounty).Column("ToCounty");
            Map(x => x.ToPostcode).Column("ToPostcode");
            Map(x => x.WaitingCharge).Column("WaitingCharge");
            Map(x => x.Fare).Column("Fare");
            Map(x => x.Note).Column("Note");
            Map(x => x.CreatedBy).Column("CreatedBy");
            Map(x => x.CreatedDate).Column("CreatedDate");
            // Map(x => x.UpdatedBy).Column("UpdatedBy)");
            Map(x => x.UpdatedDate).Column("UpdatedDate");
            Map(x => x.IsDeleted).Column("IsDeleted");
            References(x => x.Invoice).Column("InvoiceID");

            References(x => x.Customer).Column("CustomerID");
            References(x => x.Staff).Column("StaffID");
            References(x => x.PassengerDetails).Column("PassengerDetailsID").Cascade.All();
            References(x => x.BookingType).Column("BookingTypeID");
            References(x => x.FromCountry).Column("FromCountryID");
            References(x => x.ToCountry).Column("ToCountryID");
            References(x => x.Refund).Column("RefundID").Cascade.All();
            References(x => x.Status).Column("StatusID");

            HasMany(x => x.CarParkDetails).Cascade.All().KeyColumn("JobBookingID");
            //HasMany(x => x.Refund).Cascade.All().KeyColumn("JobBookingID");

           // HasOne(x => x.Refund).PropertyRef(r => r.JobBooking).Constrained().Cascade.All();
        }
    }
}
